#define allReview(getJsonType,fkurl,submiturl)
#@orderProgress()
<div style="margin-top: 15px;overflow: hidden;">
	<div class="col-md-3">
	#setLocal(tabs=["-","运营商","产品","日期","姓名","进度"])
	#setLocal(attrs=["owner","Operator","product","date","name","step"])
	#@dataTable(tabs,attrs,orderList,"/admin/photoReview")
	</div>
	#@datashowbox()
	<div class="col-md-6">
		<div style="min-height: 680px;overflow: hidden;position: relative;display: none;" id="databox">
			<div class="windowdata col-md-12" id="windowdata">
				<div class="breadcrumb">
					<ol class="col-md-9" id="breadcrumb"></ol>
					<span class="col-md-3" id="filenum">当前&nbsp;<span>0</span>&nbsp;个&nbsp;&nbsp;&nbsp;共&nbsp;<span>0</span>&nbsp;个</span>
				</div>
				<div class="filelist col-md-12">
					<ul id="filelist" style="overflow: hidden;"></ul>
					<button class="uploadbtn btn btn-default btn-sm dropdown-toggle" style="display: none;" type="button" data-loading-text="正在上传...">开始上传</button>
				</div>
			</div>
		</div>
	</div>
	<div class="col-md-3 scrollbox" id="treebox" style="display: none;">
		<div class="tree" id="tree" style="margin-bottom: 15px;"></div>
		#if(getJsonType == 16)
		<div class="form-group">
		    <div class="input-group">
		      <input class="form-control filename-hook" style="width: 76%;border-radius: 4px 0 0 4px;" type="text" placeholder="点击上传打款凭证" readonly>
		      <input style="cursor: pointer;opacity: 0;position: absolute;top: 0;left: 0;width: 76%;height: 100%;z-index: 20;" type="file" name="dkzm" data-isup="false" class="form-control" id="dkpzupload" accept="image/jpg, image/jpeg, image/png, image/gif" />
			  <button type="button" class="btn btn-default" data-loading-text="正在上传..." id="dkpzbtn">上传</button>
		    </div>
		</div>
		#end
		#if(getJsonType != 15)
		<button id="btn3" class="btn btn-primary col-md-6" data-loading-text="请稍后...">审核通过</button>
		#end
		<button id="downLoad" class="btn btn-primary col-md-6" data-toggle="modal" data-target="#alldownload">下载资料</button>
	</div>
</div>
<div id="loginModal" class="modal" style="display:none">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" onclick="$('#loginModal').modal('hide')">x</button>
				<h1 class="text-center text-primary">选择生成项</h1>
			</div>
			<div class="modal-body" style="overflow: hidden;">
				<form action="" class="form col-md-12 center-block">
					<div class="form-group" id="exportContent">
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script src="/assets/js/common.js"></script>
<script>
	$(function(){
		var allData = null,
			$power = false,//是否有权限操作
			treeDom = $("#tree"),//资源目录
			windowdata = $("#windowdata"),//窗口
			filelist = $("#filelist"),//文件列表
			filenum = $("#filenum"),//文件个数
			allFileNum = 0,//文件总个数
			datashowbox = $("#datashowbox"),//数据统计
			databox = $("#databox"),//数据展示层
			breadcrumb = $("#breadcrumb"),//面包屑导航
			fkmessage = $("#message-text"),//反馈输入框
			showimg = $("#showimg"),//背景层
			imgbox = showimg.children(".imgbox"),//可视区域
			imgboxW = imgbox.width(),
			imgboxH = imgbox.height(),
			imgul = imgbox.children("ul.imgul"),//图片容器
			modal_dialog = imgbox.children(".modal-dialog"),//反馈弹出框
			acIndex = -1,//切换索引默认等于-1
			loadingHtml = "<div class='css3loadingbox' style='position: absolute;top: 50%;left: 50%;margin: -40px 0 0 -40px;'>"+
						  "    <div class='line-spin-fade-loader'>"+
						  "        <div></div>"+
						  "        <div></div>"+
						  "        <div></div>"+
						  "	       <div></div>"+
					 	  "	       <div></div>"+
						  "	       <div></div>"+
						  "	       <div></div>"+
						  "	       <div></div>"+
						  "    </div>"+
						  "</div>";
		
		//获取宽度高度后隐藏
		showimg.removeAttr("style").hide()
	
		function getJson(type,orderId){
			var params = {
				params: {
					type:type,
					orderId:orderId
				}
			}
			return axios.get("/admin/getJson",params)
		}
		
		var treeHtml = "",
			allDownLoadHtml = "",
			dirindex = 0;
		
		$("#rtable").on("click","tbody tr",function(){
			if($(this).hasClass("sel"))return;
			var orderId = $(this).data("orderid");
			$power = $(this).data("power")
			console.log(typeof $power)
			$(this).addClass("sel").siblings("tr").removeClass("sel");
			axios.all([getJson("#(getJsonType)",orderId),getJson(7,orderId),_com.getOrderProgress()])
			.then(axios.spread(function(json1,json2,progress){
				filelist.data("orderId",orderId)
				console.log(json1.data);
				treeHtml = ""
				allDownLoadHtml = ""
				datashowbox.hide();
				databox.show();
				allData = json1.data;
				treeDom.html("");
				breadcrumb.html("");
				filelist.html("");
				allFileNum = 0;
				getBaseTab(json1.data,true,"",orderId);
				filenum.children("span").eq(1).html(allFileNum).siblings("span").html(0);
				$("#treebox").show();
				
				_com.addMsg(databox,json2.data)
				_com.renderOrderProgress(progress.data)
			}))
		})
		
		var $rootPath = "",
			$fileIndex = 0
		function getBaseTab(data,root,parentPath,orderId){
			var rootHtml = "",
				rootDLHtml = ""
			for(var i = 0;i < data.length;i++){
				var isDir = data[i].isDir,
					path = parentPath
				if(isDir){
					var icon = "<span class='glyphicon glyphicon-menu-right' aria-hidden='true'></span>",
						isshow = "isshow='false'",
						isroot = "root";
					if(data[i].value.length <= 0){
						icon = "<span class='glyphicon glyphicon-menu-right' aria-hidden='true' style='opacity: 0;'></span>";
						isshow = "";
					}
					if(!root){
						isroot = "";
						path += data[i].lab + "/"
					}else{
						$rootPath = "/fileSrc/customer/"+orderId+"/资料包/"+data[i].lab + "/"
					}
					
					treeHtml += "<dl data-path='"+ $rootPath + path +"' class='tit dir "+ isroot +"' dirindex='"+ dirindex +"'><dt "+ isshow +">"+ icon + data[i].lab +"</dt><dd class='indent'>";
					allDownLoadHtml += "<dl class='tit dir "+ isroot +"' dirindex='"+ dirindex +"'><dt "+ isshow +"><input type='checkbox' class='dir check' value=''><span class='glyphicon glyphicon-menu-right' aria-hidden='true'></span>"+ data[i].lab +"</dt><dd class='indent'>";
					dirindex++;
					getBaseTab(data[i].value,false,path);
					treeHtml += "</dd></dl>";
					allDownLoadHtml += "</dd></dl>";
				}else{
					allFileNum++;
					var src = data[i].value.path,
						type = src.substring(src.lastIndexOf("."),src.lastIndexOf("?")).toLowerCase(),
						imgclz = "",
						paramter = "",//反馈提交name
						state = "",//状态
						err = "",//反馈内容
						errDom = "",//反馈提示
						errCls = "",//反馈className
						aDom = "<a href='"+ src +"'>"+ data[i].lab +"</a>";
					if(type == ".jpg" || type == ".jpeg" || type == ".png" || type == ".gif"){
						imgclz = "img";
						paramter = "data-paramter='"+ data[i].value.paramter +"'";
						state = "data-state='"+ data[i].value.state +"'";
						if(data[i].value.err)err = "data-err='"+ data[i].value.err +"'";
						aDom = data[i].lab;
						if(data[i].value.state == 3){
							errCls = "err-hook"
							errDom = "<span class='glyphicon glyphicon-info-sign err' style='color:#f0ad4e'></span>"
						}
					}
					var rootFile = "",
						downLoadSrc = src.split("?")[0]
					if(root){
						rootFile = "rootFile"
						rootHtml += "<dl class='file "+ imgclz +" "+ errCls +"' fileindex='"+ $fileIndex +"'><dt data-src='"+ src +"' "+ paramter +" "+ state +" "+ err +">"+ errDom +aDom +"</dt></dl>";
						rootDLHtml += "<dl class='file' fileindex='"+ $fileIndex +"'><dt><label><input type='checkbox' class='check sub' value='"+ downLoadSrc +"' >&nbsp;" + data[i].lab +"</label></dt></dl>";
					}else{
						allDownLoadHtml += "<dl class='"+ rootFile +" file' fileindex='"+ $fileIndex +"'><dt><label><input type='checkbox' class='check sub' value='"+ downLoadSrc +"' >&nbsp;" + data[i].lab +"</label></dt></dl>";
					}
					treeHtml += "<dl class='"+ rootFile +" file "+ imgclz +" "+ errCls +"' fileindex='"+ $fileIndex +"'><dt data-src='"+ src +"' "+ paramter +" "+ state +" "+ err +">"+ errDom +aDom +"</dt></dl>";
					
					$fileIndex++
				}
			}
			treeDom.html(treeHtml);
			$("#alldownload").find(".modal-body").html("<label class='all'><input type='checkbox' value=''>&nbsp;全选/取消全选</label>" + allDownLoadHtml);
			if(data.length === treeDom.children("dl").length){
				$("<dl class='tit dir root' dirindex='"+ dirindex +"'><dt isshow='false'><input type='checkbox' class='dir check' value=''><span class='glyphicon glyphicon-menu-right' aria-hidden='true'></span>资料包</dt><dd class='indent'>"+ rootDLHtml +"</dd></dl>").insertAfter($("#alldownload").find("label.all"))
				
				treeDom.prepend("<dl data-path='/fileSrc/customer/"+ orderId +"/资料包/' class='tit dir root' dirindex='"+ dirindex +"'><dt isshow='false'><span class='glyphicon glyphicon-menu-right' aria-hidden='true'></span>资料包</dt><dd class='indent'>"+ rootHtml +"</dd></dl>")
				getErrTip()
			}
		}
		
		//反馈提示和渲染资料包
		function getErrTip(){
			treeDom.find("dl.err-hook").each(function(){
				$(this).parents().each(function(){
					if($(this).hasClass("tree"))return false
					if($(this).hasClass("indent")){
						if($(this).siblings("dt").children(".err").length === 1)return false
						$("<span class='glyphicon glyphicon-info-sign err' style='color:#f0ad4e'></span>").insertAfter($(this).siblings("dt").children("span"))
					}
				})
			})
		}
		
		treeDom.on("click",".dir",function(e){
			e.stopPropagation();
			var dir = $(this),
				dt = dir.children("dt"),
				indent = dir.children(".indent"),
				dirIndex = dir.attr("dirindex"),
				path = dt.text()
				
			breadcrumb.html(path);
			
			if(dir.hasClass("root")){
				dir.addClass("active").siblings().removeClass("active")
				dir.siblings().each(function () {
					var _dt = $(this).children('dt')
					_dt.attr("isshow","false");
					_dt.children(".glyphicon").removeClass("glyphicon-show");
					$(this).children(".indent").hide()
				})
			}else{
				dir.parents(".root").addClass("active").siblings().removeClass("active")
			}
			
			if(windowdata.attr("dirindex") != dirIndex){
				//展示第一个文件
				var html = "",
					childir = indent.children("dl"),
					fileNum = 0,
					index = 0;//图片展示索引
				dir.find(".file").each(function(){
					var chidt = $(this).children("dt"),
						src = chidt.data("src"),
						tit = chidt.text(),
						paramter = "",//反馈提交name
						state = "",//状态
						err = "",//反馈内容
						type = src.substring(src.lastIndexOf("."),src.lastIndexOf("?")).toLowerCase(),
						imgDom = "",
						imgclz = "",
						dataIndex = "",
						downLoadHtml = "<a href='"+ src +"' class='download'></a>",
						liCls = "",
						_fileIndex = $(this).attr("fileindex")
					if(type == ".jpg" || type == ".jpeg" || type == ".png" || type == ".gif"){
						downLoadHtml = "";
						liCls = "image-hook";
						imgDom = "<img src='"+ src +"' width='100%' />";
						imgclz = "img";
						paramter = "data-paramter='"+ chidt.data('paramter') +"'";
						state = "data-state='"+ chidt.data('state') +"'";
						dataIndex = "data-index='"+ index +"'";
						index++;
						if(!_x.isEmpty(chidt.data("err")))err = "data-err='"+ chidt.data("err") +"'";
					}else if(type == ".doc" || type == ".docx"){
						imgDom = "<i class='iconfont doc'>&#xe68b;</i>";
					}else if(type == ".xlsx" || type == ".xls"){
						imgDom = "<i class='iconfont xlsx'>&#xe605;</i>";
					}
					
					var delHtml = ""
					/* 风控 复审 */
					if("#(getJsonType)" == 6 || "#(getJsonType)" == 10){
						if($power){
							delHtml = "<span class='glyphicon glyphicon-remove del server-hook'></span>"
						}
					}
					
					html += "<li fileindex='"+ _fileIndex +"' class='"+ liCls +"' "+ paramter +" "+ state +" "+ err +" "+ dataIndex +">"+
								downLoadHtml+
							"	<div class='imgbox "+ imgclz +"' data-src='"+ src +"'>"+
								imgDom+
							"	</div>"+
							"	<p>"+ tit +"</p>"+
								delHtml+
							"</li>";
					fileNum++;
				})
				
				/* 风控 复审 */
				if("#(getJsonType)" == 6 || "#(getJsonType)" == 10){
					if($power){
						html += "<li class='upload'>"+
								"	<input type='file' class='fileupload' name='"+ dir.data("path") +"' multiple />"+
								"	<div class='imgbox'>"+
								"		<i class='iconfont'>&#xe60b;</i>"+
								"	</div>"+
								"	<p>上传照片</p>"+
								"</li>";
					}
				}
				
				filelist.html(html);
				filenum.children("span").eq(0).html(fileNum);
				windowdata.attr("dirindex",dirIndex);
				windowdata.data("addindex",dirIndex);
			}
			if(dt.attr("isshow") == "false"){
				//展示目录
				dt.attr("isshow","true");
				dt.children(".glyphicon").addClass("glyphicon-show");
				indent.show();
			}else{
				dt.attr("isshow","false");
				dt.children(".glyphicon").removeClass("glyphicon-show");
				indent.hide();
			}
		})
		
		treeDom.on("click",".file",function(e){
			e.stopPropagation();
		})
		
		//展示图片
		filelist.on("click","li",function(){
			var that = $(this),
				liIndex = that.index();
			if(that.children(".imgbox").hasClass("img")){
				var paramter = that.data('paramter'),
					state = that.data('state'),
					err = that.data("err"),
					imgIndex = that.data("index"),
					dirIndex = that.parents(".windowdata").attr("dirindex"),
					showImgIndex = showimg.attr("dirIndex"),
					option = {//参数列表
						src:"",
						title:"",
						mark:true,
						isshowbtn:true,
						imgIndex:-1,
						fkBtn:(paramter === "undefined" || _x.isEmpty(paramter))?"hide":"show"
					};
				
				acIndex = -1;
				fkmessage.attr("name",paramter).val(err);
				if(dirIndex != showImgIndex){
					showimg.attr("dirindex",dirIndex);
					imgul.html("");
					that.parent().find("img").each(function(index){
						var src = $(this).attr("src"),
							title = $(this).parent().siblings("p").text(),
							_paramter = $(this).parents("li").data('paramter')
						//that.attr("_src",src)
						option.src = src;
						option.title = title;
						option.fkBtn = (paramter === "undefined" || _x.isEmpty(paramter))?"hide":"show"
						if(imgIndex == index){
							option.mark = true;
							getImg(option);
						}else{
							option.mark = false;
							getImg(option);
						}
					})
				}else{
					option.imgIndex = imgIndex;
					option.src = that.find("img").attr("src")
					option.title = that.find("p").text();
					getImg(option);
				}
				showimg.fadeIn(300);
				$('html').css("overflow","hidden")
			}/*else{
				
			}*/
		})
		
		//处理图片
		function getImg(opt){
			var src = opt.src,
				title = opt.title,
				mark = opt.mark,
				isshowbtn = opt.isshowbtn,
				imgIndex = opt.imgIndex,
				callback = opt.callback,
				isShowfkBtn = opt.fkBtn,
				image = new Image();
			image.src = src;
			var isShow = "style='display: none;'";
			/*if(isShowfkBtn === "hide"){
				isShow = "style='display: none;'";
			}*/
			
			/* 风控 复审 终审要反馈 */
			if("#(getJsonType)" == 6 || "#(getJsonType)" == 10 || "#(getJsonType)" == 13){
				isShow = "style='display: block;'";
				if($power){
					isShow = "style='display: block;'";
				}else{
					isShow = "style='display: none;'";
				}
				if(isShowfkBtn === "hide"){
					isShow = "style='display: none;'";
				}
			}else{
				if($power){
					isShow = "style='display: block;'";
				}else{
					isShow = "style='display: none;'";
				}
				if(isShowfkBtn === "hide"){
					isShow = "style='display: none;'";
				}
			}
			
			
			
			if(imgIndex == -1){		
				var liDom = $("<li></li>"),	
					dom = $("<div></div>")
				
				liDom.html(loadingHtml)
				image.onload = function(){
					liDom.html("")
					var divDom = $("<div class='info'><p>"+ title +"</p><button class='btn btn-danger' "+ isShow +">反馈</button></div>")
					dom.css({
						width: imgboxW,
						height: imgboxH,
						position: "relative"
					})
					dom.iviewer({
	                     src: src
	                });
					liDom.append(divDom).append(dom)
				}
				if(mark){
					liDom.addClass("active").siblings("li").removeClass("active")
				}
				imgul.append(liDom);
			}else{
				
				var nowLi = imgul.children("li").eq(imgIndex);
				nowLi.addClass("active").siblings("li").removeClass("active");
			}
			if(isshowbtn){
				showimg.find("ul.btn").show();
			}else{
				showimg.find("ul.btn").hide();
			}
		}
		
		//关闭图片展示
		showimg.on("click",function(e){
			$(this).fadeOut(300);
			$('html').removeAttr("style")
			modal_dialog.stop(true).fadeOut(300);
			modal_dialog.attr("isshow","false");
		})
		
		imgbox.on("click","img",function(e){
			e.stopPropagation();
		})
		
		imgbox.on("click",function(e){
			e.stopPropagation();
		})
		
		showimg.on("click","div.iviewer_common",function(e){
			e.stopPropagation()
		})
		
		//左右切换
		imgbox.children("ul.btn").children("li").on("click",function(e){
			e.stopPropagation();
			var lis = imgbox.children("ul.imgul").children("li");
			if(lis.length <= 1)return;			
			if(acIndex == -1){
				//找到active索引
				imgul.children("li").each(function(){
					if($(this).hasClass("active")){
						acIndex = $(this).index();
						return false;
					}
				})
			}
			if($(this).index()){//右边
				acIndex++;
				if(acIndex > imgul.children("li").length - 1){
					acIndex = 0;
				}
			}else{
				acIndex--;
				if(acIndex < 0){
					acIndex = imgul.children("li").length - 1;
				}
			}
			var nowLi = imgul.children("li").eq(acIndex),
				fileLi = filelist.children("li").eq(acIndex),
				paramter = fileLi.data("paramter"),
				state = fileLi.data("state"),
				err = fileLi.data("err");
			nowLi.addClass("active").siblings("li").removeClass("active");
			fkmessage.attr("name",paramter).val(err);
		})
		
		treeDom.on("click",".img",function(){
			imgul.html("");
			var that = $(this),
				dt = that.children("dt"),
				src = dt.data("src"),
				title = dt.text(),
				paramter = dt.data('paramter'),
				state = dt.data('state'),
				err = dt.data("err"),
				option = {//参数列表
					src:src,
					title:title,
					mark:true,
					isshowbtn:false,
					imgIndex:-1,
					callback:"single",
					fkBtn:(paramter === "undefined")?"hide":"show"
				};
			showimg.attr("dirindex",-1).fadeIn(300);		
			getImg(option);
			fkmessage.attr("name",paramter).val(err);
		})
		
		modal_dialog.on("click",function(e){
			e.stopPropagation();
		})
		
		imgul.on("click","button.btn",function(e){
			e.stopPropagation();
			showModal_dialog();
		})
		
		modal_dialog.on("click",".cl",showModal_dialog);
		
		//模态框展示和关闭
		function showModal_dialog(){
			if(modal_dialog.attr("isshow") == "false"){
				modal_dialog.stop(true).fadeIn(300);
				modal_dialog.attr("isshow","true")
			}else{
				modal_dialog.stop(true).fadeOut(300);
				modal_dialog.attr("isshow","false")
			}
		}
		
		//反馈提交
		$('#fksubmit').click(function(){
			var $btn = $(this)
			if(!_x.isEmpty(fkmessage.attr("name"))){
				var name,val,state;
				/* if (type == 0) {
					state = "5"
					$review.val("5")
				}else{
					state = "3"
				} */
				var val = fkmessage.val()
				if(_x.isEmpty(val)){
					fkmessage.attr("placeholder","请输入反馈内容！").focus()
					return
				}
				$btn.button('loading')
				var data = {paramterName:fkmessage.attr("name"),state:3,err:val};
				$.ajax({
					type:"post",
					url:"#(fkurl)",
					dataType:"json",
					data:data,
					success:function(data){
						if(data.code == "1"){
							modal_dialog.stop(true).fadeOut(300);
							modal_dialog.attr("isshow","false")
							_x.show_alert_sh(data.msg,true)
							//刷新逻辑
							var nowFileLi = filelist.children("li").eq(acIndex);
							nowFileLi.data("state",3).data("err",fkmessage.val());
							treeDom.find("dt[data-paramter='"+ fkmessage.attr('name') +"']").data("state",3).data("err",fkmessage.val());
							
							//当前文件夹中下一张
							acIndex++;
							if(acIndex < imgul.children("li").length){
								var nowLi = imgul.children("li").eq(acIndex),
									nextFileLi = filelist.children("li").eq(acIndex),
									paramter = nextFileLi.data("paramter"),
									state = nextFileLi.data("state"),
									err = nextFileLi.data("err");
								nowLi.addClass("active").siblings("li").removeClass("active");
								fkmessage.attr("name",paramter).val(err);
							}else{
								acIndex = imgul.children("li").length - 1;
							}
							
						}else{
							_x.show_alert_sh(data.msg,false)
						}
						$btn.button('reset')
					},
					error:function(){
						$btn.button('reset')
						_x.show_alert_sh("您的网络异常，请稍后重试！",false)
					}
				})
			}
		})
		
		//审核通过//审核通过
		$("#btn3").click(function(){//1车辆照片 2原件照片 3合同照片 4总审 5复审 6资金管理部
			var $btn = $(this).button('loading')
			if(!$power){
				_x.show_alert_submit("操作无权限",false)
				$btn.button('reset')
				return
			}
			$.getJSON("#(submiturl)",function(data){
				console.log(data)
				if(data.code == 1){
					_x.show_alert_submit(data.msg,true)
					/*$.ajax({
						type:"post",
						url:"/admin/exportbargain",
						data:{"进件表格登记.xls":"sure"},
						success:function(data){
							if (data.successList.length > 0) {
								console.log("表格已生成！");
								_x.show_alert_sh("表格已生成！",true)
							}else{
								console.log("生成表格失败！");
								_x.show_alert_sh("生成表格失败！",false)
							}
							$btn.button('reset')
						},
						error:function(){
							$btn.button('reset')
							_x.show_alert_sh("生成表格失败，请稍后重试！",false)
						}
					})*/
				}else{
					_x.show_alert_submit(data.msg,false)
				}
				$btn.button('reset')
			})
		})
		//下载进件表
		/*$("#downLoad").click(function(){
			var $btn = $(this).button('loading')
			$.ajax({
				type:"post",
				url:"/admin/downLoadAll",
				success:function(data){
					if(data.code&&data.code==0){
						_x.show_alert_sh(data.msg,false)
					}else{
						location.href = data.msg;
						_x.show_alert_sh(data.msg,true)
					}
					$btn.button('reset')
				},
				error:function(){
					$btn.button('reset')
					_x.show_alert_sh("下载失败，请稍后重试！",false)
				}
			})
		})*/
		
		//财务打款凭证上传
		var dkpzupload = $("#dkpzupload")
		dkpzupload.change(function(){
			$(this).siblings(".filename-hook").val(dkpzupload.val())
		})
		
		$("#dkpzbtn").click(function(){
			var that = $(this),
				files = dkpzupload[0].files
			console.log(files)
			if(files.length === 0){
				_x.show_alert_sh("请选择打款凭证！",false)
				that.siblings(".filename-hook").val("")
				return
			}
			
			if(files[0].size > 3145728){
				_x.show_alert_sh("请上传3M以内的图片！",false)
				that.siblings(".filename-hook").val("")
				return
			}
			that.button('loading')
			upload_file(files[0])
		})
		
		function upload_file(file){
			dkpzupload.data("isup",false)
			var xhr = new XMLHttpRequest(),
				formData = new FormData()
			formData.append(dkpzupload.attr("name"),file)
			
			xhr.open("post","/admin/uploadEvalPho",true);
			xhr.addEventListener("load",function(){
				dkpzupload.data("isup",true)
				$("#dkpzbtn").button('reset')
				_x.show_alert_sh("上传成功！",true)
			})
			
			xhr.addEventListener('error',function(e){//监听XMLHttpRequest对象的progress事件，读取完毕后触发
            	_x.show_alert_sh("上传失败,请检查您的网络！",false)
            });
			
			xhr.send(formData);
		}
		
		/* 风控 复审 */
		if("#(getJsonType)" == 6 || "#(getJsonType)" == 10){
			fileControl()
		}
		
		//上传、删除
		function fileControl(){
			filelist.on("change","input.fileupload",function(){
				var that = $(this),
	        		files = that[0].files
	        	if(files){
	        		files = [].slice.call(files);
	        		if(files.length == 0)return;
	        		
	        		showimg.attr("dirIndex",Date.now())
					if(window.FileReader){
						readImg(files,filelist);//图片预览
						filelist.parent().children("button.btn").show();
					}else{
						alert("您当前浏览器不支持图片预览功能！")
					}
	        	}
			})
			
			//读取图片
			function readImg(files,appendDom){
				var html = "",
					fileIndex = appendDom.children("li.image-hook").length
					i = 0,
					j = 0;
				var reapImg = function(){
					var file = files[i];
					if(file){
						var tit = file.name.split(".")[0],
							type = file.name.substring(file.name.lastIndexOf(".")).toLowerCase(),
							imgDom = "",
							imgclz = "";
						if(type === ".jpg" || type === ".jpeg" || type === ".png" || type === ".gif"){
							imgclz = "img";
							var reader = new FileReader()
							reader.onload = function(e){
								html = "<li class='image-hook local-hook' data-index='"+ fileIndex +"'>"+
										"	<div class='imgbox "+ imgclz +"'>"+
										"		<img src='"+ e.target.result +"' width='100%' />"+
										"	</div>"+
										"	<p>"+ tit +"</p>"+
										"	<span class='glyphicon glyphicon-remove del local-hook'></span>"+
										"	<div class='progress'></div>"+
										"</li>";
								$(html).data("file",file).insertBefore(appendDom.children("li.upload"))
								i++;
								fileIndex++
								reapImg();
							}
							reader.readAsDataURL(file);
							
						}else if(type === ".doc" || type === ".docx"){
							html = "<li class='local-hook'>"+
									"	<div class='imgbox "+ imgclz +"'>"+
									"		<i class='iconfont doc'>&#xe68b;</i>"+
									"	</div>"+
									"	<p>"+ tit +"</p>"+
									"	<span class='glyphicon glyphicon-remove del local-hook'></span>"+
									"	<div class='progress'></div>"+
									"</li>";
							$(html).data("file",file).insertBefore(appendDom.children("li.upload"))
							i++;
							reapImg();
						}else if(type === ".xlsx" || type === ".xls"){
							html = "<li class='local-hook'>"+
									"	<div class='imgbox "+ imgclz +"'>"+
									"		<i class='iconfont xlsx'>&#xe605;</i>"+
									"	</div>"+
									"	<p>"+ tit +"</p>"+
									"	<span class='glyphicon glyphicon-remove del local-hook'></span>"+
									"	<div class='progress'></div>"+
									"</li>";
							$(html).data("file",file).insertBefore(appendDom.children("li.upload"))
							i++;
							reapImg();
						}
						
						
					}
				}
				reapImg();
			}
			
			//上传
			filelist.parent().children("button.uploadbtn").click(function(){
				var that = $(this),
					localDoms = filelist.children("li.local-hook"),
					addindex = windowdata.data("addindex"),
					nowDate = Date.now()
				if(localDoms.length === 0)return
				
				that.button('loading')
				
				var upNum = 0
				
				localDoms.each(function(){
					var thatLi = $(this),
						file = thatLi.data("file")
						xhr = new XMLHttpRequest(),
	                	formData = new FormData(),
	                	progressDom = thatLi.children(".progress");
	            	formData.append(filelist.find("input.fileupload").attr("name"),file);
	        		xhr.open("post","/admin/uploadFiles",true);
	        		xhr.progressDom = xhr.upload.progressDom = progressDom;
	        		xhr.addindex = addindex
	        		xhr.addEventListener("load",function(){
	                    var result = JSON.parse(this.response);
	                    if(result.code == 1){
		        			upNum++
		        			$fileIndex++
		                    console.log("success--->"+result)
		                    this.progressDom.parent().removeClass("local-hook").attr("fileindex",$fileIndex)
		                    this.progressDom.siblings("span.del").removeClass("local-hook").addClass("server-hook")
		                    thatLi.children("div.imgbox").data("src",result.src)
		                    var fileData = result.src.substring(result.src.lastIndexOf("/") + 1).split("."),
		                    	fileName = fileData[0],
		                    	fileHtml = "<dl class='file img' fileindex='"+ $fileIndex +"'><dt data-src='"+ result.src +"?v="+ nowDate +"'>"+ fileName +"</dt></dl>",
		                    	fDLHtml = "<dl class='file' fileindex='"+ $fileIndex +"'><dt><label><input type='checkbox' class='check sub' value='"+ result.src +"'>&nbsp;"+ fileName +"</label></dt></dl>"
		                    
		                    if(fileData[1].indexOf("doc") > -1 || fileData[1].indexOf("xls") > -1){
		                    	fileHtml = "<dl class='file' fileindex='"+ $fileIndex +"'><dt data-src='"+ result.src +"?v="+ nowDate +"'><a href='"+ result.src +"?v="+ nowDate +"'>"+ fileName +"</dt></dl>"
		                    }
		                    			
		                    treeDom.find("dl[dirindex='"+ addindex +"']").children("dd.indent").append(fileHtml)
		                    $("#alldownload").find("dl[dirindex='"+ addindex +"']").children("dd.indent").append(fDLHtml)
		                    if(upNum === localDoms.length){
		                    	that.button('reset').hide()
		                    }
	                    }else{
	                    	that.button('reset')
	                    	_x.show_alert_sh(result.msg,false)
	                    }
	                    this.progressDom.fadeOut(300)
	                });
	        		
	        		xhr.upload.addEventListener('progress',function(e){
	                    if(e.lengthComputable){//是否可以计算上传字节数
	                        var percent = e.loaded / e.total;                        
	                        this.progressDom.css("width",(percent * 100) + "%");
	                    };
	                });
	        		
	        		xhr.send(formData);
				})
			})
			
			//删除
			filelist.on("click","span.del",function(e){
				e.stopPropagation()
				var that = $(this)
				if(that.hasClass("local-hook")){
					that.parent().remove()
					var index = 0
					filelist.children("li.image-hook").each(function(){
						$(this).data("index",index)
						index++
					})
					if(filelist.children("li.local-hook").length === 0){
						filelist.parent().children("button.btn").hide();
					}
				}else if(that.hasClass("server-hook")){
					var _fileindex = that.parent().attr("fileindex"),
						option = {
						isShowBg: false,
						text: "您真的要删除吗？",
						fn: function(modalDom,btn,callback){
							var $src = that.siblings("div.imgbox").data("src")
							if($src.lastIndexOf("?") > -1){
								$src = $src.substring(0,$src.lastIndexOf("?"))
							}
							axios.get("/admin/deleteEvalPho",{
								params: {
									src: decodeURI($src)
								}
							})
							.then(function(res){
								if(res.data.code == 1){
									that.parent().remove()
									var index = 0
									filelist.children("li.image-hook").each(function(){
										$(this).data("index",index)
										index++
									})
									if(filelist.children("li.local-hook").length === 0){
										filelist.parent().children("button.btn").hide();
									}
									
									treeDom.find("dl.file[fileindex='"+ _fileindex +"']").remove()
									$("#alldownload").find("dl.file[fileindex='"+ _fileindex +"']").remove()
									_x.show_alert_sh("删除成功！",true)
									callback()
								}else{
									btn.button('reset')
									_x.show_alert_sh(res.data.msg,false)
								}
							})
							.catch(function(){
								_x.show_alert_sh("删除失败！",false)
								btn.button('reset')
							})
						}
					}
					_x.show_alert_confirm(option)
				}
			})
		}
	})
</script>
#end